package cn.xopencode.appletweb.controller.record.drytransformer;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.recordservice.rpc.drytransformer.dto.DryTransformerRecordCreateDTO;
import cn.xopencode.recordservice.rpc.drytransformer.dto.DryTransformerRecordPageDTO;
import cn.xopencode.recordservice.rpc.drytransformer.dto.DryTransformerRecordUpdateDTO;
import cn.xopencode.recordservice.rpc.drytransformer.vo.DryTransformerRecordEmpRelVO;
import cn.xopencode.recordservice.rpc.drytransformer.vo.DryTransformerRecordPageVO;
import cn.xopencode.recordservice.rpc.drytransformer.vo.DryTransformerRecordUpdateVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Api(tags = "10KV干式变压器巡检记录 API")
@RestController
@RequestMapping("/drytransformer")
@Validated
public class DryTransformerRecordController {

    /**
     * 根据查询条件 分页获取所有的10KV干式变压器巡检记录
     * @param pageDTO
     * @return
     */
    @PostMapping("/getAllByQuery")
    @ApiOperation("根据查询条件分页获取所有的10KV干式变压器巡检记录")
    public CommonResult<PageResult<DryTransformerRecordPageVO>> getPageDryTransformerRecord(DryTransformerRecordPageDTO pageDTO){
        PageResult<DryTransformerRecordPageVO> result = new PageResult<>();
        List<DryTransformerRecordPageVO> list = new ArrayList<>();

        DryTransformerRecordPageVO vo = new DryTransformerRecordPageVO();
        vo.setInspectionTime(new Date());
        vo.setEmpRels("张三、李四");
        list.add(vo);
        DryTransformerRecordPageVO vo2 = new DryTransformerRecordPageVO();
        vo2.setInspectionTime(new Date());
        vo2.setEmpRels("王一");
        list.add(vo2);
        result.setList(list);
        return CommonResult.success(result);
    }

    /**
     *  新增 10KV干式变压器巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/add")
    @ApiOperation("新增 10KV干式变压器巡检记录")
    public CommonResult<Integer> createDryTransformerRecord(@Valid DryTransformerRecordCreateDTO roomDTO){
        return CommonResult.success(1);
    }

    /**
     *  更新 10KV干式变压器巡检记录
     * @param roomDTO
     * @return
     */
    @PostMapping("/update")
    @ApiOperation("更新 10KV干式变压器巡检记录")
    public CommonResult<Integer> updateDryTranformerRecord(@Valid DryTransformerRecordUpdateDTO roomDTO){
        return CommonResult.success(1);
    }

    /**
     * 根据id获取10KV干式变压器巡检记录详细
     * @param roomId
     * @return
     */
    @GetMapping("/getById")
    @ApiOperation("根据id获取10KV干式变压器巡检记录详细")
    public CommonResult<DryTransformerRecordUpdateVO> getDryTranformerRecordById(String roomId){
        DryTransformerRecordUpdateVO vo = new DryTransformerRecordUpdateVO();
        vo.setInspectionTime(new Date());
        vo.setATemperature(33.45);
        vo.setBTemperature(35.43);
        vo.setCTemperature(36.43);
        vo.setFrontTemperature(35.43);
        vo.setBackTemperature(36.43);
        vo.setStart(true);
        vo.setNormal(true);
        vo.setId("332343242334");

        List<DryTransformerRecordEmpRelVO> list = new ArrayList<DryTransformerRecordEmpRelVO>();
        DryTransformerRecordEmpRelVO relVO = new DryTransformerRecordEmpRelVO();
        relVO.setEmpId("111");
        relVO.setId("11");
        relVO.setRecordId("332343242334");
        DryTransformerRecordEmpRelVO relVO2 = new DryTransformerRecordEmpRelVO();
        relVO2.setEmpId("222");
        relVO2.setId("22");
        relVO2.setRecordId("332343242334");
        list.add(relVO);
        list.add(relVO2);

        vo.setEmpList(list);
        return CommonResult.success(vo);
    }
}
